<template>
    <div class="dailySongs">
        <div class="description">
            <img :src="this.Url">
            <div class="text">
                <h1>每日歌曲推荐</h1>
                <div class="title">
                    <p>根据您的口味生成，每天 6:00 更新</p>
                </div>
                <div class="btn">
                    <span>
                        <button class="fa fa-play">播放全部</button>
                        <button class="fa fa-plus"></button>
                    </span>
                    <span class="fa fa-star-o">
                        收藏
                    </span>
                </div>
            </div>
        </div>
        <div class="List">
            <table>
            <thead>
                <td style="width:100px">操作</td>
                <td style="width:450px">标题</td>
                <td>歌手</td>
                <td style="width:300px">专辑</td>
                <td style="width:125px">时长</td>
            </thead>
            <tbody @dblclick="getUrl(id)" v-for="({id,dt,ar,al,tns,name,item},index) in list" :key="item">
                <td>
                    <i>{{getIndex(index)}}</i>
                    <i class="fa fa-heart-o cursor" id="heart"></i>
                    <i class="fa fa-download cursor" id="download"></i>
                </td>
                <td>{{name}}
                    <a v-for="trans in tns" :key="trans">
                        <i>( {{trans}} )</i>
                    </a>
                </td>
                <td>{{ar[0].name}}</td>
                <td>{{al.name}}</td>
                <td>{{formatTime(dt)}}</td>
            </tbody>
        </table>
        </div>
    </div>
</template>

<script>
import {
    recommendS
} from '@/library/api/api'
export default {
    name:'dailySongs',
    data() {
        return {
            list:{},
            Url:""
        }
    },
    methods:{
        getUrl(id) {
            localStorage.musicId = id
            this.$store.commit('increment', id)
        },
        getIndex(index) {
            return index+1<10?'0'+(index+1):index+1
        },
        songs() {
            recommendS({
                data:{
                    cookie:localStorage.cookie
                }
            }).then(res=>{
                // console.log(res.data.dailySongs);
                this.Url = res.data.dailySongs[0].al.picUrl
                this.list = res.data.dailySongs.map(item=>{
                    return item
                })
            })
        }
    },
    created() {
        this.songs()
    }
}
</script>

<style lang="scss" scoped>
@import './dailySongs.scss'
</style>
